﻿using System;
using System.Web.Services;
using Monkey.Warrenty.Biz;
using Monkey.Warrenty.Constants;
using MonkeyWarranty.Web.Common;
using Resources;

namespace MonkeyWarranty.Web.Reports.InstantTicketReports
{
    public partial class EmployeeReport : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (WarrantyCommon.CurrrentEmployee == null)
            {
                Response.Redirect("~/Logon.aspx");
                return;
            }

            if (!WarrantyCommon.CurrrentEmployee.HasRole(RoleConstant.Admin))
            {
                Response.Redirect("~/NoPermission.aspx");
            }
        }

        [WebMethod(EnableSession = true)]
        public static object ReportEmployee(string dateFrom, string dateTo)
        {
            var results = ReportingBiz.ReportEmployeeInstantTicket(dateFrom, dateTo, GlobalStrings.DateFormat);
            return new { Result = "OK", Records = results };
        }
    }
}